import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter)



//解决重复点击编程式导航产生的问题
const originalPush = VueRouter.prototype.push
const originalReplace = VueRouter.prototype.replace
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
VueRouter.prototype.replace = function replace(location) {
    return originalReplace.call(this, location).catch(err => err)
}



import routes from "routes/routes"
const router = new VueRouter({
    routes,
    mode:"history",
    linkActiveClass:"active",
    scrollBehavior (to, from, savedPosition) {
        return {x:0,y:0}
    }
})

//加载路由守卫钩子
import definedFn from "util/routerDefined.js"
definedFn(router)

export default router